<?php include "../public/header.php";?>
<?php include "../public/header_edit.php";?>
<link rel="stylesheet" type="text/css" href="/static/component/laytp/module/cityPicker/city-picker.css">

<body id="optPage">
<form class="layui-form layui-form-pane" id="commentForm">
    <div class="page-title"><div class="page-title-con"><span id="flowsetname"></span><div class="move_title"></div><?php include "../public/subturn.php";?></div></div>
    <div class="main-container">
        <div class="block-generic">
            <div class="layui-form-item">
                <div class="layui-row layui-col-space10">
                    <div class="layui-col-md6">
                        <label class="layui-form-label">申请人</label>
                        <div class="layui-input-block">
                            <input type="text" id="flowuser" readonly placeholder="请输入" autocomplete="off" class="layui-input readonly">
                        </div>
                    </div>
                    <div class="layui-col-md6">
                        <label class="layui-form-label">申请部门</label>
                        <div class="layui-input-block">
                            <input type="text" id="flowdept" readonly placeholder="请输入" autocomplete="off" class="layui-input readonly">
                        </div>
                    </div>
                </div>
            </div>


            <div class="layui-form-item">
                <div class="layui-row layui-col-space10">
                    <div class="edittits"><span>基本信息</span></div>
                </div>
            </div>

            <div class="layui-form-item">
                <div class="layui-row layui-col-space10">
                    <div class="layui-col-md12">
                        <label class="layui-form-label"><text>*</text>经营类别</label>
                        <div class="layui-input-block">
                            <select id="jinglei" name="jinglei" lay-filter="jinglei">
                                <option value="">请选择</option>
                                <option value="总公司">总公司</option>
                                <option value="分公司(办事处)">分公司(办事处)</option>
                            </select>
                            <p class="error" id="jinglei_error" style="margin: 0;"></p>
                        </div>
                    </div>
                </div>
            </div>
            <div class="layui-form-item">
                <div class="layui-row layui-col-space10">
                    <div class="layui-col-md6">
                        <label class="layui-form-label"><text>*</text>工程名称</label>
                        <div class="layui-input-block">
                            <input type="text" name="name" id="name" placeholder="请输入" clearable autocomplete="off" class="layui-input">
                        </div>
                    </div>
                    <div class="layui-col-md6">
                        <label class="layui-form-label">工程编号</label>
                        <div class="layui-input-block">
                            <input type="text" name="number" id="number" placeholder="请输入" clearable autocomplete="off" class="layui-input">
                        </div>
                    </div>
                </div>
            </div>
            <div class="layui-form-item">
                <div class="layui-row layui-col-space10">
                    <div class="layui-col-md6">
                        <label class="layui-form-label"><text>*</text>甲方名称</label>
                        <div class="layui-input-block">
                            <input type="text" readonly name="jiaer" class="layui-input jiaer" onclick="openPage('../public/choose_dealcom.php?dom=jiaer','80%','80%')">
                            <div class="choose_div" id="jiaer" key="1"></div>
                            <span class="choose_one" onclick="openPage('../public/choose_dealcom.php?dom=jiaer','80%','80%')"><i class="layui-icon layui-icon-search"></i></span>
                        </div>
                    </div>
                    <div class="layui-col-md6">
                        <label class="layui-form-label">工程负责人</label>
                        <div class="layui-input-block">
                            <input type="text" readonly name="gofuer" class="layui-input gofuer" onclick="openPage('../public/choose_dealcom.php?dom=gofuer','80%','80%')">
                            <div class="choose_div" id="gofuer" key="0"></div>
                            <span class="choose_one" onclick="openPage('../public/choose_dealcom.php?dom=gofuer','80%','80%')"><i class="layui-icon layui-icon-search"></i></span>
                        </div>
                    </div>
                </div>
            </div>
            <div class="layui-form-item">
                <div class="layui-row layui-col-space10">
                    <div class="layui-col-md6">
                        <label class="layui-form-label">所在地</label>
                        <div class="layui-input-block" style="z-index: 1;">
                            <input type="text" name="areas" id="areas" placeholder="请选择" readonly clearable autocomplete="off" class="layui-input">
                        </div>
                    </div>
                    <div class="layui-col-md6">
                        <label class="layui-form-label">详细地址</label>
                        <div class="layui-input-block">
                            <input type="text" name="addr" id="addr" placeholder="请输入" clearable autocomplete="off" class="layui-input">
                        </div>
                    </div>
                </div>
            </div>
            <div class="layui-form-item">
                <div class="layui-row layui-col-space10">
                    <div class="layui-col-md6">
                        <label class="layui-form-label"><text>*</text>投标单位</label>
                        <div class="layui-input-block">
                            <div class="tanxian">
                                <div class="tanxianclick" onclick="openPage('../public/choose_userpart.php?dom=tou_unit&type=dept&dept=chan&single=1','770px','490px');"></div>
                                <div class="tanxiannei" id="tou_unit"></div>
                            </div>
                            <div class="tancheckdiv"><div class="tancheck" onclick="openPage('../public/choose_userpart.php?dom=tou_unit&type=dept&dept=chan&single=1','770px','490px');"><i class="layui-icon layui-icon-search"></i></div></div>
                            <div id="tou_unit_tanerror" class="tanerrormsg"></div>
                        </div>
                    </div>
                    <div class="layui-col-md6">
                        <label class="layui-form-label"><text>*</text>业务归属</label>
                        <div class="layui-input-block">
                            <div class="tanxian">
                                <div class="tanxianclick" onclick="openPage('../public/choose_userpart.php?dom=gui_unit&type=dept&dept=chan&single=1','770px','490px');"></div>
                                <div class="tanxiannei" id="gui_unit"></div>
                            </div>
                            <div class="tancheckdiv"><div class="tancheck" onclick="openPage('../public/choose_userpart.php?dom=gui_unit&type=dept&dept=chan&single=1','770px','490px');"><i class="layui-icon layui-icon-search"></i></div></div>
                            <div id="gui_unit_tanerror" class="tanerrormsg"></div>
                        </div>
                    </div>
                </div>
            </div>
            <div class="layui-form-item">
                <div class="layui-row layui-col-space10">
                    <div class="layui-col-md6">
                        <label class="layui-form-label"><text>*</text>报备方式</label>
                        <div class="layui-input-block">
                            <div id="lanshi"></div>
                        </div>
                    </div>
                    <div class="layui-col-md6">
                        <label class="layui-form-label">资金来源</label>
                        <div class="layui-input-block">
                            <div id="zilai"></div>
                        </div>
                    </div>
                </div>
            </div>
            <div class="layui-form-item">
                <div class="layui-row layui-col-space10">
                    <div class="layui-col-md6">
                        <label class="layui-form-label">报名截止时间</label>
                        <div class="layui-input-block">
                            <input type="text" name="enddt_bao" id="enddt_bao" readonly placeholder="请选择" clearable  autocomplete="off" class="layui-input bdate_ymdhi">
                        </div>
                    </div>
                    <div class="layui-col-md6">
                        <label class="layui-form-label">投标截止时间</label>
                        <div class="layui-input-block">
                            <input type="text" name="enddt_tou" id="enddt_tou" readonly placeholder="请选择" clearable  autocomplete="off" class="layui-input bdate_ymdhi">
                        </div>
                    </div>
                </div>
            </div>
            <div class="layui-form-item">
                <div class="layui-row layui-col-space10">
                    <div class="layui-col-md6">
                        <label class="layui-form-label">开标时间</label>
                        <div class="layui-input-block">
                            <input type="text" name="kaidt" id="kaidt" readonly placeholder="请选择" clearable  autocomplete="off" class="layui-input bdate_ymdhi">
                        </div>
                    </div>
                    <div class="layui-col-md6">
                        <label class="layui-form-label">开标地点</label>
                        <div class="layui-input-block">
                            <input type="text" name="kaiaddr" id="kaiaddr" placeholder="请输入" clearable autocomplete="off" class="layui-input">
                        </div>
                    </div>
                </div>
            </div>
            <div class="layui-form-item">
                <div class="layui-row layui-col-space10">
                    <div class="layui-col-md6">
                        <label class="layui-form-label"><text>*</text>开标类型</label>
                        <div class="layui-input-block">
                            <div id="kaitype"></div>
                        </div>
                    </div>
                    <div class="layui-col-md6">
                        <label class="layui-form-label"><text>*</text>工程发布平台</label>
                        <div class="layui-input-block">
                            <div id="kailei"></div>
                        </div>
                    </div>
                </div>
            </div>
            <div class="layui-form-item">
                <div class="layui-row layui-col-space10">
                    <div class="layui-col-md6">
                        <label class="layui-form-label">资质要求</label>
                        <div class="layui-input-block">
                            <input type="text" name="gongzi" id="gongzi" placeholder="请输入" clearable autocomplete="off" class="layui-input">
                        </div>
                    </div>
                    <div class="layui-col-md6">
                        <label class="layui-form-label">投标文件份数</label>
                        <div class="layui-input-block ">
                            <input type="text" name="tounums" id="tounums" placeholder="请输入" clearable autocomplete="off" class="layui-input">
                        </div>
                    </div>
                </div>
            </div>
            <div class="layui-form-item">
                <div class="layui-row layui-col-space10">
                    <div class="layui-col-md6">
                        <label class="layui-form-label"><text>*</text>招标方式</label>
                        <div class="layui-input-block">
                            <div id="zhaotype"></div>
                        </div>
                    </div>
                    <div class="layui-col-md6">
                        <label class="layui-form-label">招标代理公司</label>
                        <div class="layui-input-block">
                            <input type="text" readonly name="zhao_unit" class="layui-input zhao_unit" onclick="openPage('../public/choose_dealcom.php?dom=zhao_unit','80%','80%')">
                            <div class="choose_div" id="zhao_unit" key="0"></div>
                            <span class="choose_one" onclick="openPage('../public/choose_dealcom.php?dom=zhao_unit','80%','80%')"><i class="layui-icon layui-icon-search"></i></span>
                        </div>
                    </div>
                </div>
            </div>
            <div class="layui-form-item">
                <div class="layui-row layui-col-space10">
                    <div class="layui-col-md6">
                        <label class="layui-form-label">工程控制价(元)</label>
                        <div class="layui-input-block">
                            <input type="text" id="kongfee" name="kongfee" placeholder="请输入" clearable autocomplete="off" class="layui-input moneyinput">
                        </div>
                    </div>
                    <div class="layui-col-md6">
                        <label class="layui-form-label">工期(天)</label>
                        <div class="layui-input-block ">
                            <input type="text" name="gongqi" id="gongqi" placeholder="请输入" clearable autocomplete="off" class="layui-input">
                        </div>
                    </div>
                </div>
            </div>
            <div class="layui-form-item">
                <div class="layui-row layui-col-space10">
                    <div class="layui-col-md12">
                        <label class="layui-form-label">投标保证金</label>
                        <div class="layui-input-block ">
                            <input type="text" name="toubaojin" id="toubaojin" placeholder="请输入" clearable autocomplete="off" class="layui-input">
                        </div>
                    </div>
                </div>
            </div>
            <div class="layui-form-item">
                <div class="layui-row layui-col-space10">
                    <div class="layui-col-md6">
                        <label class="layui-form-label">经营备案人</label>
                        <div class="layui-input-block">
                            <div class="tanxian">
                                <div class="tanxianclick" onclick="openPage('../public/choose_userpart.php?dom=jinger&type=user&single=1', '770px', '490px');"></div>
                                <div class="tanxiannei" id="jinger"></div>
                            </div>
                            <div class="tancheckdiv"><div class="tancheck" onclick="openPage('../public/choose_userpart.php?dom=jinger&type=user&single=1', '770px', '490px');"><i class="layui-icon layui-icon-search"></i></div></div>
                            <div id="jinger_tanerror" class="tanerrormsg"></div>
                        </div>
                    </div>
                    <div class="layui-col-md6">
                        <label class="layui-form-label">投标负责人</label>
                        <div class="layui-input-block">
                            <div class="tanxian">
                                <div class="tanxianclick" onclick="openPage('../public/choose_userpart.php?dom=touer&type=user&single=1', '770px', '490px');"></div>
                                <div class="tanxiannei" id="touer"></div>
                            </div>
                            <div class="tancheckdiv"><div class="tancheck" onclick="openPage('../public/choose_userpart.php?dom=touer&type=user&single=1', '770px', '490px');"><i class="layui-icon layui-icon-search"></i></div></div>
                            <div id="touer_tanerror" class="tanerrormsg"></div>
                        </div>
                    </div>
                </div>
            </div>
            <div class="layui-form-item">
                <div class="layui-row layui-col-space10">
                    <div class="layui-col-md12">
                        <label class="layui-form-label"><text>*</text>业绩是否录入平台</label>
                        <div class="layui-input-block">
                            <select id="islu" name="islu" lay-filter="islu">
                                <option value="">请选择</option>
                                <option value="是">是</option>
                                <option value="否">否</option>
                            </select>
                            <p class="error" id="islu_error" style="margin: 0;"></p>
                        </div>
                    </div>
                </div>
            </div>
            <div class="layui-form-item height_auto">
                <div class="layui-row layui-col-space10">
                    <div class="layui-col-md12">
                        <label class="layui-form-label label_textarea">备注</label>
                        <div class="layui-input-block">
                            <textarea id="explain" name="explain" placeholder="请输入" class="layui-textarea"></textarea>
                        </div>
                    </div>
                </div>
            </div>
            <div class="layui-form-item">
                <div class="layui-row layui-col-space10">
                    <div class="layui-col-md12">
                        <label class="layui-form-label">关联流程</label>
                        <div class="layui-input-block">
                            <input type="text" readonly name="flowrelas" class="layui-input flowrelas" onclick="openPage('../public/choose_flowrelas.php?dom=flowrelas','80%','80%');">
                            <div class="choose_div" id="flowrelas" key="1"></div>
                            <span class="choose_one" onclick="openPage('../public/choose_flowrelas.php?dom=flowrelas','80%','80%');"><i class="layui-icon layui-icon-search"></i></span>
                        </div>
                    </div>
                </div>
            </div>
            <div class="layui-form-item layui-hide" id="advanersDiv">
                <div class="layui-row layui-col-space10">
                    <div class="layui-col-md12">
                        <label class="layui-form-label">预审人</label>
                        <div class="layui-input-block relative">
                            <div class="tanxian">
                                <div class="tanxianclick" onclick="openPage('../public/choose_userpart.php?dom=advaners&type=user&single=2','770px','490px');"></div>
                                <div class="tanxiannei" id="advaners"></div>
                            </div>
                            <div class="tancheckdiv"><div class="tancheck" onclick="openPage('../public/choose_userpart.php?dom=advaners&type=user&single=2','770px','490px');"><i class="layui-icon layui-icon-search"></i></div></div>
                        </div>
                    </div>
                </div>
            </div>
            <div class="layui-form-item layui-hide" id="nexterDiv">
                <div class="layui-row layui-col-space10">
                    <div class="layui-col-md12">
                        <label class="layui-form-label"><text>*</text>指定下一步审核人</label>
                        <div class="layui-input-block relative">
                            <div class="tanxian">
                                <div class="tanxianclick" onclick="openPage('../public/choose_userpart.php?dom=nexter&type=user&single=1','770px','490px');"></div>
                                <div class="tanxiannei" id="nexter"></div>
                            </div>
                            <div class="tancheckdiv"><div class="tancheck" onclick="openPage('../public/choose_userpart.php?dom=nexter&type=user&single=1','770px','490px');"><i class="layui-icon layui-icon-search"></i></div></div>
                        </div>
                    </div>
                </div>
            </div>
            <?php include '../public/upinfo.php'?>

        </div>

    </div>
</form>
<script>
    var param_id = getQueryVariable('id') || 0;
    var param_isturn = getQueryVariable('isturn') || 0;
    if(param_isturn > 0){
        $("#billzhan").remove();
        $("#billtutn").remove();
        $("#billsub").attr('isshen', 1);
    }
    var param_billyushen = getQueryVariable('billyushen') || 0;
    if(param_billyushen == 2){
        $("#billyushen").addClass('layui-hide');
    }

    $("#commentForm").validate({
        rules: {
            name: {required: true},
        },
        messages:{
            name: {required: "请输入"},
        }
    });

    layui.use(['laytp', 'form'], function() {
        var form = layui.form, layer = layui.layer;
        render_input_attr();

        facade.ajax({type: 'get', url: ask_flowdata_edit_bid,data:{id:param_id}}).done(function(res){
            if (res.code === 2000) {
                var data = res.data.data;
                $("#flowsetname").text(data.flowsetname);
                $("#flowuser").val(data.flowuser);
                $("#flowdept").val(data.flowdept);
                if(data.isadvan){
                    $("#advanersDiv").removeClass('layui-hide');
                    if(data.advaners_info.length > 0){
                        tan_tags_init('#advaners', data.advaners_info);
                    }
                }
                if(data.isnext){
                    $("#nexterDiv").removeClass('layui-hide');
                    if(data.nexter_info.length > 0){
                        tan_tags_init('#nexter', data.nexter_info);
                    }
                }
                if(data.flowrelas_info.length > 0){
                    set_choose_btn_more('flowrelas',data.flowrelas_info);
                }



                $('#jinglei').val(data.jinglei);
                $('#name').val(data.name);
                $('#number').val(data.number);
                $('#addr').val(data.addr);
                $('#kaidt').val(data.kaidt);
                $('#kaiaddr').val(data.kaiaddr);
                $('#gongzi').val(data.gongzi);
                $('#tounums').val(data.tounums);
                $('#kongfee').val(data.kongfee);
                $('#gongqi').val(data.gongqi);
                $('#toubaojin').val(data.toubaojin);
                $('#enddt_bao').val(data.enddt_bao);
                $('#enddt_tou').val(data.enddt_tou);
                $('#islu').val(data.islu);
                $('#explain').val(data.explain);


                if(data.jiaer){
                    set_choose_btn('jiaer',data.jiaer,data.jiaer);
                }

                if(data.tou_unit_info.length > 0){
                    tan_tags_init('#tou_unit', data.tou_unit_info);
                }
                if(data.gui_unit_info.length > 0){
                    tan_tags_init('#gui_unit', data.gui_unit_info);
                }

                if(data.gofuer){
                    set_choose_btn('gofuer',data.gofuer,data.gofuer);
                }
                if(data.zhao_unit){
                    set_choose_btn('zhao_unit',data.zhao_unit,data.zhao_unit);
                }


                if(data.jinger_info.length > 0){
                    tan_tags_init('#jinger', data.jinger_info);
                }
                if(data.touer_info.length > 0){
                    tan_tags_init('#touer', data.touer_info);
                }



                $("#areas").val(data.areas);
                load_areas('areas', res.data.areas, 3);
                xmselect_dan('lanshi', res.data.lanshi, data.lanshi, function (res) {
                    if(res.arr && res.arr.length > 0){
                        $("#lanshi").find('xm-select').removeClass('error');
                    }else{
                        $("#lanshi").find('xm-select').addClass('error');
                    }
                });
                xmselect_dan('zilai', res.data.zilai, data.zilai);
                xmselect_dan('kaitype', res.data.kaitype, data.kaitype, function (res) {
                    if(res.arr && res.arr.length > 0){
                        $("#kaitype").find('xm-select').removeClass('error');
                    }else{
                        $("#kaitype").find('xm-select').addClass('error');
                    }
                });
                xmselect_dan('kailei', res.data.kailei, data.kailei);
                xmselect_dan('zhaotype', res.data.zhaotype, data.zhaotype, function (res) {
                    if(res.arr && res.arr.length > 0){
                        $("#zhaotype").find('xm-select').removeClass('error');
                    }else{
                        $("#zhaotype").find('xm-select').addClass('error');
                    }
                });




                public_upload_file_load('upload_files', res.data.files);
                render_date();
                render_from();
                initParseMoney();
            }
        });

        form.on('select(jinglei)', function(data){
            if(data.value == ''){
                $('#jinglei_error').show().text('请选择');
                $('#jinglei_error').parent().find('input').addClass('select_error');
            }else{
                $('#jinglei_error').hide();
                $('#jinglei_error').parent().find('input').removeClass('select_error');
            }
        });

        form.on('select(islu)', function(data){
            if(data.value == ''){
                $('#islu_error').show().text('请选择');
                $('#islu_error').parent().find('input').addClass('select_error');
            }else{
                $('#islu_error').hide();
                $('#islu_error').parent().find('input').removeClass('select_error');
            }
        });

        form.on('submit(add)', function(data){
            data.field.isturn = $(this).attr('key') || 0;
            data.field.isshen = $(this).attr('isshen') || 0;
            data.field.flowrelas = get_choose_val('flowrelas');
            data.field.advaners = tan_tags_getvalue("#advaners", 'user');
            data.field.nexter = tan_tags_getvalue("#nexter", 'user');

            data.field.jiaer = get_choose_val('jiaer');
            data.field.gofuer = get_choose_val('gofuer');
            data.field.tou_unit = tan_tags_getvalue("#tou_unit", 'dept');
            data.field.gui_unit = tan_tags_getvalue("#gui_unit", 'dept');
            data.field.zhao_unit = get_choose_val('zhao_unit');
            data.field.jinger = tan_tags_getvalue("#jinger", 'user');
            data.field.touer = tan_tags_getvalue("#touer", 'user');

            if(data.field.isturn > 0){
                var validRes = $("#commentForm").valid();

                if(data.field.jinglei == ''){
                    $('#jinglei_error').show().text('请选择');
                    $('#jinglei_error').parent().find('input').addClass('select_error');
                    validRes = false;
                }else{
                    $('#jinglei_error').hide();
                    $('#jinglei_error').parent().find('input').removeClass('select_error');
                }


                formValid('jiaer');
                if(data.field.jiaer == undefined || !data.field.jiaer){
                    validRes = false;
                }

                if(!data.field.tou_unit){
                    $("#tou_unit").parents('.tanxian').addClass('tanerror');
                    $('#tou_unit_tanerror').text('请选择');
                    validRes = false;
                }else{
                    $("#tou_unit").parents('.tanxian').removeClass('tanerror');
                    $('#tou_unit_tanerror').text('');
                }
                if(!data.field.gui_unit){
                    $("#gui_unit").parents('.tanxian').addClass('tanerror');
                    $('#gui_unit_tanerror').text('请选择');
                    validRes = false;
                }else{
                    $("#gui_unit").parents('.tanxian').removeClass('tanerror');
                    $('#gui_unit_tanerror').text('');
                }

                if(!data.field.lanshi){
                    $("#lanshi").find('xm-select').addClass('error');
                    validRes = false;
                }else{
                    $("#lanshi").find('xm-select').removeClass('error');
                }

                if(!data.field.kaitype){
                    $("#kaitype").find('xm-select').addClass('error');
                    validRes = false;
                }else{
                    $("#kaitype").find('xm-select').removeClass('error');
                }

                if(!data.field.kailei){
                    $("#kailei").find('xm-select').addClass('error');
                    validRes = false;
                }else{
                    $("#kailei").find('xm-select').removeClass('error');
                }
                if(!data.field.zhaotype){
                    $("#zhaotype").find('xm-select').addClass('error');
                    validRes = false;
                }else{
                    $("#zhaotype").find('xm-select').removeClass('error');
                }
                if(data.field.islu == ''){
                    $('#islu_error').show().text('请选择');
                    $('#islu_error').parent().find('input').addClass('select_error');
                    validRes = false;
                }else{
                    $('#islu_error').hide();
                    $('#islu_error').parent().find('input').removeClass('select_error');
                }
                if(!validRes){return false;}
            }

            data = parseMoney(data);
            data.field.id = param_id;
            data.field.files = public_upload_file_value('upload_files');

            public_flow_submit(data.field, ask_flowdata_add_bid, ask_flowdata_edit_bid, $(this).attr('but'));
            return false;
        });

    });


</script>
</body>
</html>
